package com.cash.channel.api.model.response;

import com.cash.channel.api.model.DataModel;
import com.google.common.collect.Lists;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

@Data
public class LoanCalculateResponse implements DataModel, Serializable {

    private BigDecimal actualAmount;

    private BigDecimal payAmount;

    private BigDecimal serviceFee;

    private BigDecimal payFee;

    private String remark;

    private List<CalculateRepayPlan> repayPlan;

    public void addCalculateRepayPlan(Integer tenor, Date payDate, BigDecimal payAmount, BigDecimal payCorpus, BigDecimal payFee, BigDecimal serviceCharge) {
        if (this.repayPlan==null) {
            this.repayPlan = Lists.newLinkedList();
        }
        this.repayPlan.add(new CalculateRepayPlan(tenor, payDate.getTime(), payAmount
                , payCorpus, payFee, serviceCharge));
    }

    @Data
    public class CalculateRepayPlan implements Serializable {

        Integer tenor;
        Long payDate;
        BigDecimal payAmount = BigDecimal.ZERO;
        BigDecimal payCorpus = BigDecimal.ZERO;
        BigDecimal payFee = BigDecimal.ZERO;
        BigDecimal serviceCharge = BigDecimal.ZERO;

        public CalculateRepayPlan() {
        }

        public CalculateRepayPlan(Integer tenor, Long payDate, BigDecimal payAmount, BigDecimal payCorpus, BigDecimal payFee, BigDecimal serviceCharge) {
            this.tenor = tenor;
            this.payDate = payDate;
            this.payAmount = payAmount;
            this.payCorpus = payCorpus;
            this.payFee = payFee;
            this.serviceCharge = serviceCharge;
        }
    }

}
